<html lang="en-US">

<head>
    
<title>gitea&#43;drone配置自动化部署 - 花落雨忧</title>

<meta property="og:title" content="gitea&#43;drone配置自动化部署 - 花落雨忧">



    



    
    <meta property="description" content="docker-compose.yml
[&amp;hellip;] version: &amp;#34;3.7&amp;#34; networks: www: external: true services: gitea: image: gitea/gitea:1.16.9 container_name: gitea environment: - USER_UID=1000 - USER_GID=1000 - &amp;hellip;">
    <meta property="og:description" content="docker-compose.yml
[&amp;hellip;] version: &amp;#34;3.7&amp;#34; networks: www: external: true services: gitea: image: gitea/gitea:1.16.9 container_name: gitea environment: - USER_UID=1000 - USER_GID=1000 - &amp;hellip;">
    






<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1">

<link rel="shortcut icon" href="https://www.lican.asia/logo/logo.png" type="image/x-icon" />



<link rel="stylesheet" href="/css/style.min.css" />

<link rel="stylesheet" href="/css/reset.min.css" />




<script src="https://www.lican.asia/js/highlight.min.js"></script>

<script>
hljs.configure({ ignoreUnescapedHTML: true })
hljs.highlightAll();
</script>


<script src="https://www.lican.asia/js/jquery.min.js"></script>




<link href="https://www.lican.asia/css/hugo-code.min.css" rel="stylesheet" />



    <style>
        .post-content img {
            max-width: 400px;
        }
    </style>
</head>

<body id="period" class="home blog">
    <a class="skip-content" href="#main">Press "Enter" to skip to content</a>
    <div id="overflow-container" class="overflow-container">
        <header class="site-header" id="site-header" role="banner">
    <div class="max-width">
        <div id="title-container" class="title-container">
            <div id="site-title" class="site-title"><a href="/">花落雨忧</a></div>
            <p class="tagline">思所及 力所行 方为真.</p>
        </div>
        
        <div id="menu-primary-container" class="menu-primary-container">
            <div class="icon-container">
            </div>
            <div id="menu-primary" class="menu-container menu-primary" role="navigation">
                <nav class="menu">
                    <ul id="menu-primary-items" class="menu-primary-items">
                        
                        
                        <li id="menu-item-0"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/posts" aria-current="page" tabindex="0">首页</a></li>
                        
                        <li id="menu-item-1"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/tech/" aria-current="page" tabindex="1">技术文档</a></li>
                        
                        <li id="menu-item-2"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/article/" aria-current="page" tabindex="2">文章</a></li>
                        
                        <li id="menu-item-3"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/project/" aria-current="page" tabindex="3">项目</a></li>
                        
                        <li id="menu-item-4"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/about/" aria-current="page" tabindex="4">关于</a></li>
                        
                    </ul>
                </nav>
            </div>
        </div>
    </div>
</header>

        <div id="primary-container" class="primary-container">
            <div class="max-width">
                <section id="main" class="main" role="main">
                    <div id="loop-container" class="loop-container">
                        <div
                            class="post type-post status-publish format-standard hentry entry">
                            <article>
                                <div class="post-container">
                                    <div class="post-header">
                                        <h2 class="post-title">
                                            <a href="/tech/gitea&#43;drone%E6%90%AD%E5%BB%BA%E9%A1%B9%E7%9B%AE%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/">gitea&#43;drone配置自动化部署</a>
                                        </h2>
                                        
                                    </div>
                                    <div class="post-content">
                                        <h3 id="git--drone搭建项目自动部署">git + drone搭建项目自动部署</h3>
<h4 id="step1下载安装gitea">step1：下载安装gitea</h4>
<blockquote>
<p>docker-compose.yml</p>
</blockquote>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">version</span>: <span style="color:#e6db74">&#34;3.7&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">networks</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">www</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">external</span>: <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">services</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">gitea</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">gitea/gitea:1.16.9</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">container_name</span>: <span style="color:#ae81ff">gitea</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">environment</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">USER_UID=1000</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">USER_GID=1000</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">DB_TYPE=mysql</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">DB_HOST= mysql:3306</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">DB_NAME=gitea</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">DB_USER=root</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">DB_PASSWD=lican520</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">restart</span>: <span style="color:#ae81ff">always</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">networks</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">www</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">volumes</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">./gitea:/data</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">./etc/timezone:/etc/timezone:ro</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">./etc/localtime:/etc/localtime:ro</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">expose</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">22</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">3000</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">logging</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">driver</span>: <span style="color:#ae81ff">json-file</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">options</span>:
</span></span><span style="display:flex;"><span>         <span style="color:#f92672">max-size</span>: <span style="color:#e6db74">&#34;100M&#34;</span> <span style="color:#75715e"># 单个文件大小为200k</span>
</span></span><span style="display:flex;"><span>         <span style="color:#f92672">max-file</span>: <span style="color:#e6db74">&#34;10&#34;</span> <span style="color:#75715e"># 最多10个文件</span>
</span></span></code></pre></div><p>注意：当docker-compose无法拉取gitea安装包时，可以从<a href="https://pan.baidu.com/s/1geZWmAslEEevfs5yWlCFzA?pwd=1234">gitea.tar</a>拉取，我们通过</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">docker</span> <span style="color:#a6e22e">save</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">o</span> <span style="color:#a6e22e">gitea</span>.<span style="color:#a6e22e">tar</span> <span style="color:#a6e22e">gitea</span><span style="color:#f92672">/</span><span style="color:#a6e22e">gitea</span>:<span style="color:#ae81ff">1.16.9</span>
</span></span></code></pre></div><p>保存的安装包，下载后， 仅需docker load -i gitea.tar即可</p>
<blockquote>
<p>安装之前，需要先安装一个mysql容器，gitea依赖mysql存储</p>
</blockquote>
<p>服务启动后，可以配置nginx转发，配置域名，通过域名访问</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">server</span> {
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">listen</span> <span style="color:#ae81ff">80</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">listen</span> <span style="color:#ae81ff">443</span> <span style="color:#a6e22e">ssl</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">ssl_certificate</span>      .<span style="color:#f92672">/</span><span style="color:#a6e22e">ssl</span><span style="color:#f92672">/*</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span><span style="color:#f92672">/</span><span style="color:#a6e22e">fullchain</span>.<span style="color:#a6e22e">pem</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">ssl_certificate_key</span>  .<span style="color:#f92672">/</span><span style="color:#a6e22e">ssl</span><span style="color:#f92672">/*</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span><span style="color:#f92672">/</span><span style="color:#a6e22e">key</span>.<span style="color:#a6e22e">pem</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">server_name</span> <span style="color:#a6e22e">git</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">if</span> (<span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">args</span> ~<span style="color:#f92672">*</span> <span style="color:#e6db74">&#34;^go-get=1&#34;</span>) {
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">set</span> <span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">condition</span> <span style="color:#a6e22e">goget</span>;
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">if</span> (<span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">uri</span> ~ ^<span style="color:#f92672">/</span>([<span style="color:#a6e22e">a</span><span style="color:#f92672">-</span><span style="color:#a6e22e">zA</span><span style="color:#f92672">-</span><span style="color:#a6e22e">Z0</span><span style="color:#f92672">-</span><span style="color:#ae81ff">9_</span><span style="color:#f92672">-</span>]<span style="color:#f92672">+</span>)<span style="color:#f92672">/</span>([<span style="color:#a6e22e">a</span><span style="color:#f92672">-</span><span style="color:#a6e22e">zA</span><span style="color:#f92672">-</span><span style="color:#a6e22e">Z0</span><span style="color:#f92672">-</span><span style="color:#ae81ff">9_</span><span style="color:#f92672">-</span>]<span style="color:#f92672">+</span>)<span style="color:#f92672">/</span>.<span style="color:#f92672">*</span><span style="color:#960050;background-color:#1e0010">$</span>) {
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">set</span> <span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">condition</span> <span style="color:#e6db74">&#34;${condition}path&#34;</span>;
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">if</span> (<span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">condition</span> = <span style="color:#a6e22e">gogetpath</span>) {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> <span style="color:#ae81ff">200</span> <span style="color:#e6db74">&#34;&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;meta content=&#39;git.nongbotech.com/$1/$2 git https://git.nongbotech.com/$1/$2.git&#39; name=&#39;go-import&#39;&gt;&lt;/head&gt;&lt;/html&gt;&#34;</span>;
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">location</span> <span style="color:#f92672">/</span> {
</span></span><span style="display:flex;"><span>       <span style="color:#a6e22e">add_header</span> <span style="color:#a6e22e">Access</span><span style="color:#f92672">-</span><span style="color:#a6e22e">Control</span><span style="color:#f92672">-</span><span style="color:#a6e22e">Allow</span><span style="color:#f92672">-</span><span style="color:#a6e22e">Origin</span> <span style="color:#f92672">*</span>;
</span></span><span style="display:flex;"><span>       <span style="color:#a6e22e">proxy_pass</span> <span style="color:#a6e22e">http</span>:<span style="color:#75715e">//gitea:3000;
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>通过域名访问后，配置数据库登录参数，即可来到登录页面，登录后，可创建代码仓库</p>
<p><img src="C:%5CUsers%5CAdministrator%5CAppData%5CRoaming%5CTypora%5Ctypora-user-images%5C1720062673243.png" alt="1720062673243"></p>
<p>创建gitea和drone授权应用</p>
<p>右上角-&gt;设置-&gt;应用-&gt;创建应用</p>
<p>应用名称：自定义,我暂且填drone</p>
<p>重定向URL: 跳转到drone的地址，为drone访问地址加上/login,例如我配置的drone访问地址是https://drone.nongbotech.com. 所以此处填写https://drone.nongbotech.com/login</p>
<blockquote>
<p>创建完gitea应用后，会有客户端ID,和客户端密钥</p>
</blockquote>
<h4 id="step-2-下载安装drone-server和drone-runner">step 2: 下载安装drone-server和drone-runner</h4>
<blockquote>
<p>docker-compose.yml</p>
</blockquote>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">version</span>: <span style="color:#960050;background-color:#1e0010">&#39;</span><span style="color:#ae81ff">3.7</span><span style="color:#960050;background-color:#1e0010">&#39;</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">services</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">server</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">drone</span><span style="color:#f92672">/</span><span style="color:#a6e22e">drone</span>:<span style="color:#ae81ff">2.8.0</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">container_name</span>: <span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">server</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">ports</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#e6db74">&#34;3003:3000&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">volumes</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> .<span style="color:#f92672">/</span><span style="color:#a6e22e">drone</span>:<span style="color:#f92672">/</span><span style="color:#a6e22e">data</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">localtime</span>:<span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">localtime</span>:<span style="color:#a6e22e">ro</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">environment</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_USER_CREATE</span>=<span style="color:#a6e22e">username</span>:<span style="color:#a6e22e">lican</span>,<span style="color:#a6e22e">admin</span>:<span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_GITEA_CLIENT_ID</span>=<span style="color:#a6e22e">bcb76646</span><span style="color:#f92672">-</span><span style="color:#ae81ff">56</span><span style="color:#a6e22e">b0</span><span style="color:#f92672">-</span><span style="color:#ae81ff">42</span><span style="color:#a6e22e">ab</span><span style="color:#f92672">-</span><span style="color:#ae81ff">8</span><span style="color:#a6e22e">f11</span><span style="color:#f92672">-</span><span style="color:#a6e22e">ecd2e5a1bea2</span> <span style="color:#75715e">// gitea应用的客户端ID
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_GITEA_CLIENT_SECRET</span>=<span style="color:#ae81ff">0</span><span style="color:#a6e22e">VHtKBja73k6Oe7yMGGzbfOvogjKYITpiOzsmoHej6X1</span> <span style="color:#75715e">// gitea应用的客户端密钥
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_GITEA_SERVER</span>=<span style="color:#a6e22e">http</span>:<span style="color:#75715e">//git.nongbotech.com  #gitea访问地址
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_GIT_ALWAYS_AUTH</span>=<span style="color:#66d9ef">false</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RPC_SECRET</span>=<span style="color:#ae81ff">50</span><span style="color:#a6e22e">f491d1154873d72f3cedc710d01d59</span> <span style="color:#75715e">// drone-server和drone-runner间的通信密钥，可通过指令生成[openssl rand -hex 16]
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_SERVER_HOST</span>=<span style="color:#a6e22e">drone</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span>  <span style="color:#75715e">// drone访问地址
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_SERVER_PROTO</span>=<span style="color:#a6e22e">https</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">restart</span>: <span style="color:#a6e22e">always</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">networks</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">www</span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">runner</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">drone</span><span style="color:#f92672">/</span><span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">runner</span><span style="color:#f92672">-</span><span style="color:#a6e22e">docker</span>:<span style="color:#ae81ff">1.8.0</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">container_name</span>: <span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">runner</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">volumes</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#f92672">/</span><span style="color:#66d9ef">var</span><span style="color:#f92672">/</span><span style="color:#a6e22e">run</span><span style="color:#f92672">/</span><span style="color:#a6e22e">docker</span>.<span style="color:#a6e22e">sock</span>:<span style="color:#f92672">/</span><span style="color:#66d9ef">var</span><span style="color:#f92672">/</span><span style="color:#a6e22e">run</span><span style="color:#f92672">/</span><span style="color:#a6e22e">docker</span>.<span style="color:#a6e22e">sock</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">environment</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RPC_PROTO</span>=<span style="color:#a6e22e">http</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RPC_HOST</span>=<span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">server</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RPC_SECRET</span>=<span style="color:#ae81ff">50</span><span style="color:#a6e22e">f491d1154873d72f3cedc710d01d59</span> <span style="color:#75715e">// drone-server和drone-runner间的通信密钥，可通过指令生成[openssl rand -hex 16]
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RUNNER_CAPACITY</span>=<span style="color:#ae81ff">3</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RUNNER_NAME</span>=<span style="color:#a6e22e">drone_runner</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_CPU_SHARES</span>=<span style="color:#ae81ff">300</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_MEMORY_LIMIT</span>=<span style="color:#ae81ff">2000000000</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RUNNER_VOLUMES</span>=.<span style="color:#f92672">/</span><span style="color:#a6e22e">nbi_dev</span>:<span style="color:#f92672">/</span><span style="color:#a6e22e">www_dev</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">restart</span>: <span style="color:#a6e22e">always</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">networks</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">www</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">networks</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">www</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">external</span>: <span style="color:#66d9ef">true</span>
</span></span></code></pre></div><p><a href="https://pan.baidu.com/s/19tuKOxt9sP-mVxp0He3YRQ?pwd=1234">drone-server.tar</a></p>
<p><a href="https://pan.baidu.com/s/1GBDCYSu36dNbAZrR06GLCA?pwd=1234">drone-runner.tar</a></p>
<p><a href="https://juejin.cn/post/7145763787201593381">配置参数指引</a></p>
<p>配置nginx转发drone服务</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">server</span> {
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">listen</span> <span style="color:#ae81ff">80</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">listen</span> <span style="color:#ae81ff">443</span> <span style="color:#a6e22e">ssl</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">ssl_certificate</span>      .<span style="color:#f92672">/</span><span style="color:#a6e22e">ssl</span><span style="color:#f92672">/*</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span><span style="color:#f92672">/</span><span style="color:#a6e22e">fullchain</span>.<span style="color:#a6e22e">pem</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">ssl_certificate_key</span>  .<span style="color:#f92672">/</span><span style="color:#a6e22e">ssl</span><span style="color:#f92672">/*</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span><span style="color:#f92672">/</span><span style="color:#a6e22e">key</span>.<span style="color:#a6e22e">pem</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">server_name</span> <span style="color:#a6e22e">drone</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">location</span> <span style="color:#f92672">/</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">proxy_pass</span> <span style="color:#a6e22e">http</span>:<span style="color:#75715e">//drone-server:80;
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>1.drone-server和drone-runner服务启动后， 点击右上角的SYNC按钮即可同步gitea刚刚创建的代码仓库</p>
<p>2.点击同步到的代码仓库，进入页面后点击Settings按钮</p>
<ul>
<li>
<p>General: 最下面一行配置超时时间和钩子执行的.drone.yml文件</p>
</li>
<li>
<p>Secrets: 配置drone访问服务器的基本参数，该参数在.drone.yml文件中通过该变量访问服务器</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Value</th>
<th>Remark</th>
</tr>
</thead>
<tbody>
<tr>
<td>DRONE_SSH_HOST</td>
<td>120.77.213.80</td>
<td>服务器ip地址</td>
</tr>
<tr>
<td>DRONE_SSH_USER</td>
<td>root</td>
<td>用户名</td>
</tr>
<tr>
<td>DRONE_SSH_PORT</td>
<td>22</td>
<td>端口号</td>
</tr>
<tr>
<td>DRONE_SSH_KEY</td>
<td>&mdash;&ndash;BEGIN OPENSSH PRIVATE KEY&mdash;&ndash;</td>
<td></td>
</tr>
<tr>
<td>&mdash;&ndash;END OPENSSH PRIVATE KEY&mdash;&ndash;</td>
<td>服务器访问私钥&mdash;&mdash;&ndash;登录服务器后，通过运行指令ssh-keygen -t rsa -b 4096生成后，进入~/.ssh后，打开id_rsa文件，复制可得。</td>
<td></td>
</tr>
<tr>
<td>当远程失败时，复制id_rsa.pub到同级目录的authorized_keys中，每个公钥都单独一行。并使用命令如 ssh -i /path/to/private_key user@host 进行测试</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>配置完成之后，推送代码到gitea的仓库中，即可看到触发了drone的运行，需要在项目的指定位置放置.drone.yml文件</p>
<p>.drone.yml文件示例</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">kind</span>: <span style="color:#a6e22e">pipeline</span> <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">对象类型</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">type</span>: <span style="color:#a6e22e">docker</span> <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">管道类型</span><span style="color:#960050;background-color:#1e0010">，</span><span style="color:#a6e22e">drone支持不同的类型</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">name</span>: <span style="color:#e6db74">&#34;brewing-sass&#34;</span> <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">管道名称</span><span style="color:#960050;background-color:#1e0010">，</span><span style="color:#a6e22e">一个项目可以有多个管道</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">克隆设置</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">clone</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">disable</span>: <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">触发条件</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">trigger</span>:
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span>  <span style="color:#a6e22e">event</span>:
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span>    <span style="color:#f92672">-</span> <span style="color:#a6e22e">tag</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">管道步骤</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">steps</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">base</span><span style="color:#f92672">-</span><span style="color:#a6e22e">setup</span>
</span></span><span style="display:flex;"><span>  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">基础后台设置服务</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">-</span> <span style="color:#a6e22e">name</span>: <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span> <span style="color:#a6e22e">clone</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">alpine</span><span style="color:#f92672">/</span><span style="color:#a6e22e">git</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">environment</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">GOOS</span>: <span style="color:#a6e22e">linux</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">GOARCH</span>: <span style="color:#a6e22e">amd64</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">commands</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">git</span> <span style="color:#a6e22e">clone</span> <span style="color:#a6e22e">http</span>:<span style="color:#75715e">//git.dev.nongbotech.cn/back-end-3.0/brewing-sass.git brewing-sass
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">编译</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">-</span> <span style="color:#a6e22e">name</span>: <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span> <span style="color:#a6e22e">build</span> <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">管道步骤名称</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">golang</span>:<span style="color:#ae81ff">1.16.9</span> <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">执行shell命令的docker镜像</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">environment</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">GOOS</span>: <span style="color:#a6e22e">linux</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">GOARCH</span>: <span style="color:#a6e22e">amd64</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">commands</span>: <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">定义在docker容器内作为容器入口点执行的shell命令列表</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#66d9ef">go</span> <span style="color:#a6e22e">env</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">w</span> <span style="color:#a6e22e">GOPRIVATE</span>=<span style="color:#a6e22e">git</span>.<span style="color:#a6e22e">dev</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">cn</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#66d9ef">go</span> <span style="color:#a6e22e">env</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">w</span> <span style="color:#a6e22e">GOPROXY</span>=<span style="color:#a6e22e">https</span>:<span style="color:#75715e">//goproxy.cn
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>      <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#f92672">-</span> <span style="color:#66d9ef">go</span> <span style="color:#a6e22e">get</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">u</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">v</span> <span style="color:#a6e22e">git</span>.<span style="color:#a6e22e">dev</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">cn</span><span style="color:#f92672">/</span><span style="color:#a6e22e">back</span><span style="color:#f92672">-</span><span style="color:#a6e22e">end</span><span style="color:#f92672">-</span><span style="color:#ae81ff">3.0</span><span style="color:#f92672">/</span><span style="color:#a6e22e">pkg</span>
</span></span><span style="display:flex;"><span>      <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#f92672">-</span> <span style="color:#66d9ef">go</span> <span style="color:#a6e22e">get</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">u</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">v</span> <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span><span style="color:#f92672">/</span><span style="color:#a6e22e">gopkg</span><span style="color:#f92672">/</span><span style="color:#a6e22e">logger</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">cd</span> <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#66d9ef">go</span> <span style="color:#a6e22e">mod</span> <span style="color:#a6e22e">tidy</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#66d9ef">go</span> <span style="color:#a6e22e">build</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">o</span> <span style="color:#a6e22e">brewing_sass_app</span>
</span></span><span style="display:flex;"><span>  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">发布</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">-</span> <span style="color:#a6e22e">name</span>: <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span> <span style="color:#a6e22e">publish</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">appleboy</span><span style="color:#f92672">/</span><span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">scp</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">settings</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">host</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_HOST</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">port</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_PORT</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">user</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_USER</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">key</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_KEY</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">target</span>: <span style="color:#f92672">/</span><span style="color:#a6e22e">data</span><span style="color:#f92672">/</span><span style="color:#a6e22e">nbi_dev</span><span style="color:#f92672">/</span><span style="color:#a6e22e">soa</span><span style="color:#f92672">/</span><span style="color:#a6e22e">dev</span><span style="color:#f92672">-</span><span style="color:#a6e22e">soa_backend</span><span style="color:#f92672">/</span><span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">source</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">-</span> <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span><span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">app</span>.<span style="color:#a6e22e">yaml</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">-</span> <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span><span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">rsa</span><span style="color:#f92672">/</span><span style="color:#a6e22e">private</span>.<span style="color:#a6e22e">pem</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">-</span> <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span><span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">rsa</span><span style="color:#f92672">/</span><span style="color:#a6e22e">public</span>.<span style="color:#a6e22e">pem</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">-</span> <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span><span style="color:#f92672">/</span><span style="color:#a6e22e">brewing_sass_app</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">strip_components</span>: <span style="color:#ae81ff">1</span> <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">去除前缀</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">服务重启</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">-</span> <span style="color:#a6e22e">name</span>: <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span> <span style="color:#a6e22e">reboot</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">appleboy</span><span style="color:#f92672">/</span><span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">ssh</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">settings</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">host</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_HOST</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">port</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_PORT</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">username</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_USER</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">key</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_KEY</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">script</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">-</span> <span style="color:#a6e22e">cd</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">data</span><span style="color:#f92672">/</span><span style="color:#a6e22e">nbi_dev</span><span style="color:#f92672">/</span><span style="color:#a6e22e">soa</span><span style="color:#f92672">/</span><span style="color:#a6e22e">dev</span><span style="color:#f92672">-</span><span style="color:#a6e22e">soa_backend</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">-</span> <span style="color:#a6e22e">docker</span><span style="color:#f92672">-</span><span style="color:#a6e22e">compose</span> <span style="color:#a6e22e">down</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">-</span> <span style="color:#a6e22e">docker</span><span style="color:#f92672">-</span><span style="color:#a6e22e">compose</span> <span style="color:#a6e22e">up</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">d</span>
</span></span></code></pre></div></li>
</ul>


                                        
                                    </div>

                                    

                                    

                                    
                                    
                                    

                                </div>
                            </article>
                        </div>
                    </div>
                </section>
                <aside class="sidebar sidebar-primary" id="sidebar-primary" role="complementary">
    <h1 class="screen-reader-text">Sidebar</h1>
    

    
    
    <section id="text-2" class="widget widget_text">
        <div class="textwidget">
            
            <div id="profile">
                <div id="profile_picture"><img src="https://www.lican.asia/logo/logo.png"></div>
                <div id="profile_intro">
                    <p><span class="name">Lican</span></p>
                    <p class="intro">全栈开发者，爱好造轮子。</p>
                </div>
            </div>
            
            <p>
                <script type="text/javascript">
                    (function ($) {
                        $(document).ready(function () {
                            var menuPrimaryContainer = $('#menu-primary-container');
                            var profile = $('#text-2');
                            $('#toggle-navigation').click(function () {
                                if (menuPrimaryContainer.hasClass('open')) {
                                    profile.removeClass('open');
                                } else {
                                    profile.addClass('open');
                                }
                            });
                        });
                    })(jQuery);
                </script>
            </p>
        </div>
    </section>
    
    
    
    
    
    <section id="text-5" class="widget widget_text">
        <h2 class="widget-title">开源项目</h2>
        <div class="textwidget">
            <div id="projects" style="line-height: 22px;">
                
                <a href="https://github.com/idoubi/gonews"
                    target="_blank">gonews</a>: &nbsp;Daily news for golang<br>
                
                <a href="https://github.com/idoubi/sql2struct"
                    target="_blank">sql2struct</a>: &nbsp;Generate go struct according to SQL<br>
                
                <a href="https://github.com/idoubi/goz"
                    target="_blank">goz</a>: &nbsp;Request library used in golang<br>
                
        </div>
    </section>
    
    

    
    
    
    
    <section id="qrcode" class="widget widget_media_image">
        <h2 class="widget-title">微信公众号</h2>
        <img width="258" height="258"
            src="https://www.lican.asia/wechat/lican.png"
            class="image wp-image-5514  attachment-full size-full" alt=""
            style="max-width: 100%; height: auto;"
            sizes="(max-width: 258px) 100vw, 258px">
    </section>
    
    

    
    
    

    
    
    

    
    
    
    
</aside>
            </div>
        </div>

        <footer id="site-footer" class="site-footer" role="contentinfo">
    <div class="max-width">
    </div>
    <div class="footer">
        <div id="footercontent">
            © lican.asia All rights reserved<br/>
            Built with Hugo Theme <a href="https://github.com/idoubi/hugo-theme-period" target="_blank">Period</a>
        </div>
    </div>
</footer>

<script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?e8351b6d4626d5881d439ea1f6184baa";
      var s = document.getElementsByTagName("script")[0]; 
      s.parentNode.insertBefore(hm, s);
    })();
</script>
    
    
    </div>
    
</body>

</html>